package org.neptune.service.service;

import org.neptune.api.request.SeckillRequest;
import org.neptune.api.response.SeckillResponse;

public interface SeckillService {

	/**
	 * 限流 没有加锁，数量可能出现错误
	 * <p>
	 * 线程不安全
	 *
	 * @param seckillRequest
	 * @return
	 */
	default SeckillResponse seckillByAopLimit(SeckillRequest seckillRequest) {
		return null;
	}

	/**
	 * 公平锁
	 * <p>
	 * 线程安全
	 *
	 * @param seckillRequest
	 * @return
	 */
	SeckillResponse seckillByReentranLock(SeckillRequest seckillRequest);

	/**
	 * aop加锁
	 *
	 * @param seckillRequest
	 * @return
	 */
	SeckillResponse seckillByAopLock(SeckillRequest seckillRequest);

	boolean updateSeckillGoods(SeckillRequest seckillRequest, int count);

	boolean updateSeckillGoodsByLock(SeckillRequest seckillRequest, int count);

	/**
	 * 秒杀 走缓存
	 * <p>
	 *
	 * @param seckillRequest
	 * @return
	 */
	SeckillResponse seckillByCache(SeckillRequest seckillRequest);
}
